import { MeasurementUnit } from '../basicData/measurementUnit.js';
import { CommodityCategory } from '../basicData/commodityCategory.js';
import { Commodity } from '../commodity/commodity.js';
import { SubCommodity } from '../commodity/subcommodity.js';
import { CsFundDouble } from '../common/csFundDouble.js';
import { WareHouse } from '../inventory/warehouse.js';
import { SubCommodityWarehouseInventoryData } from '../commodity/subcommodityWarehouseInventoryData.js';
import { CsDouble } from '../common/csDouble.js';
import { Customer } from '../targetOrg/customer.js';
import { Supplier } from '../targetOrg/supplier.js';
import { Inventory, CommodityBatch, InventoryInOutType, InventoryInOutRecord } from '../inventory/inventory.js';
import {
    CommonOrderStatus, ProgressState, DocType,
    OrderResultCategoryItemType, OrderResultCategoryType, ContractManufacturingStatus
} from '../common/docDefinition.js';
import { PendingInventory, CommodityPendingBatch } from '../inventory/pendingInventory.js';
import { Store } from '../store/store.js';
import { StoreEmployeeRelation } from '../store/storeEmployee.js';
import { Employee } from '../enterpriseMgt/employee.js';
import { Role } from '../enterpriseMgt/role.js';
import { Engine } from '../engine.js';
import { InventoryType } from '../inventory/inventoryType.js';
import { OrderResultCategoryItem, OrderResultCategory, OrderResult } from '../common/orderResult.js';
import { SubCommodityInventorySumData } from '../commodity/subCommodityInventorySum.js';
import { InventoryAssembler } from '../inventory/inventoryAssembler.js';
import { InventorySheet, CommodityBatchSheet } from '../inventory/inventorySheet.js';
import { FundAccount } from '../funds/fundAccount.js';
import { PurchaseContract } from '../purchase/purchaseContract.js';
import { ReceiveOrder, PendingReceiveOrderRelation } from '../funds/receiveOrder.js';
import { PendingReceiveOrder } from '../funds/pendingReceiveOrder.js';
import { MetalRefiningContract, MentalRefiningBatch } from '../metal/metalRefiningContract.js';
import { PendingPaymentOrder } from '../funds/pendingPaymentOrder.js';
import { PaymentOrder, PendingPaymentOrderRelation } from '../funds/paymentOrder.js';
import { PaymentFundType } from '../common/fundDefinition.js';
import { PermissionInfo } from '../menus/permissionInfo.js';
import { FunctionPermissionData } from '../platform/functionPermissionData.js';
import { MerchantActivePackage } from '../merchantOrg/merchantActivePackage.js';
import { MerchantPackage } from '../merchantOrg/merchantPackage.js';
import { MerchantPackageAuthAccount } from '../merchantOrg/merchantPackageAuthAccount.js';
import { Profile, UserAccountType } from '../user/profile.js';
import { MerchantOrg } from '../merchantOrg/merchantOrg.js';
import { MerchantCandidateMgr } from '../merchantOrg/merchantCandidateMgr.js';
import { MetalCombineOrder } from '../metal/metalCombineOrder.js';
import { CommodityBatchWithTax } from '../sales/sales.js'
import {PeriodSettlementOrder } from '../periodSettlement/periodSettlementOrder.js';

export class TestSimulateData {

    /// 模拟登录用户和账户数据2
    simLoginProfileAndMerchant() {
        let profile = new Profile();

        profile.id = '1';
        profile.userName = 'simAdmin';
        profile.nickName = 'simAdmin';
        profile.token = 'simAdmin';
        profile.pwd = 'simAdmin';
        profile.mobPhoneNum = '13000000000';
        profile.accountType = UserAccountType.OrgInternalAccount;

        profile.enabled = true;
        profile.accessAllStoreData = true;

        let simOrg = this.simMerchantOrg();
        profile.candidateOrg = new MerchantCandidateMgr();
        profile.candidateOrg.dataList.push(simOrg);
        // profile.permissionMgr = this.simulatePermissionInfoWithAllPermission(); 

        return profile;
    }

    /// 模拟商户信息
    simMerchantOrg() {
        let org = new MerchantOrg();

        org.orgId = 'simMerchantOrg';
        //org.updateSettings(todo);
        //org.updateRetailSettings(todo);
        org.activePkg = this.simMerchantActivePackage();
        org.publicStore = this.simStoreData();
        org.orgPermissionInfo = org.activePkg.permissionInfo;
        return org;
    }

    /// 模拟全部权限FunctionPermissionData
    simulatePermissionInfoWithAllPermission() {
        return PermissionInfo.fromJson(
            (new FunctionPermissionData()).simAllPermissionTree());
    }

    /// 模拟企业套餐
    simMerchantActivePackage() {
        let merchantPkg = new MerchantPackage({
            id: "1",
            name: "模拟测试套餐",
            orgId: "1",
            platformPkgId: "1",
            startDate: new Date(2025, 1, 1),
            endDate: new Date(2115, 1, 1),
            authAccountData: [
                new MerchantPackageAuthAccount({
                    startTime: new Date(2025, 1, 1),
                    endTime: new Date(2115, 1, 1),
                    count: 3
                })
            ],
            isTrialMode: false,
            price: 0,
            discountPrice: 0,
            spanMonth: 12,
            pkgLimitation: "",  // 不填写模拟权限
            pkgPermission: "",  // 不填写模拟权限
            minAccountNum: 1,

        });

        // 模拟完整权限
        merchantPkg.permissionInfo = this.simulatePermissionInfoWithAllPermission();

        return merchantPkg;
    }

    // 生成计量单位模拟数据
    createSimMeasurementUnitData() {
        let unitList = [];

        unitList.push(new MeasurementUnit("1", "斤", true));
        unitList.push(new MeasurementUnit("2", "个"));
        unitList.push(new MeasurementUnit("3", "双"));
        unitList.push(new MeasurementUnit("4", "件"));


        for (let i = 0; i < 16; i++) {
            unitList.push(new MeasurementUnit((i + 5).toString(), i + "个"));
        }


        return unitList;

    }

    /// 生成计量单位模拟数据
    createSimCommodityCategoryData() {
        let unitList = [];
        unitList.push(new CommodityCategory("1", "衣服"));
        unitList.push(new CommodityCategory("2", "裤子"));
        unitList.push(new CommodityCategory("3", "袜子"));
        unitList.push(new CommodityCategory("4", "这是一个名字很长的测试类别，看看会怎么样显示"));

        for (let i = 0; i < 16; i++) {
            unitList.push(new MeasurementUnit((i + 5).toString(), i + "类别"));
        }

        return unitList;
    }

    /// 模拟商品信息
    createSimCommodityData() {
        let retList = [];

        let commodity = new Commodity({
            id: "1",
            code: "code1",
            name: "短袖",
            qrCode: "qrCode1",
            coverUri: "https://img0.baidu.com/it/u=2864706542,2917157997&fm=253&fmt=auto&app=138&f=JPEG",
            unit: this.createSimMeasurementUnitData()[1],
            category: this.createSimCommodityCategoryData()[2],
            remark: "remark1",
            purchasePrice: new CsFundDouble(13.3),
            retailPrice: new CsFundDouble(19.9),
            wholesalePrice: new CsFundDouble(16.9),
            count: new CsDouble(12),
            subCommodityList: [this.createSimSubCommodityData()[0]]  // 单规格
        });
        commodity.subCommodityList[0].commodity = commodity;

        retList.push(commodity);

        ///

        commodity = new Commodity({
            id: "2",
            code: "code2",
            name: "短裤",
            qrCode: "qrCode2",
            coverUri: "",
            unit: this.createSimMeasurementUnitData()[1],
            category: this.createSimCommodityCategoryData()[0],
            remark: "remark2",
            purchasePrice: new CsFundDouble(15.3),
            retailPrice: new CsFundDouble(18.9),
            wholesalePrice: new CsFundDouble(17.9),
            count: new CsDouble(56),
            multiStandard: true, // 多规格
            subCommodityList: [this.createSimSubCommodityData()[1]]
        });

        commodity.subCommodityList[0].commodity = commodity;
        retList.push(commodity);

        retList.push(new Commodity({
            id: "3",
            code: "code3",
            name: "这是一个名字很长的商品，看看显示是否有溢出，如果没有溢出则没有问题",
            qrCode: "qrCode2",
            coverUri: "",
            unit: this.createSimMeasurementUnitData()[1],
            category: this.createSimCommodityCategoryData()[0],
            remark: "remark2",
            purchasePrice: new CsFundDouble(15.3),
            retailPrice: new CsFundDouble(18.9),
            wholesalePrice: new CsFundDouble(17.9),
            count: new CsDouble(56),
        }));

        return retList;
    }

    /// 模拟子商品信息
    createSimSubCommodityData() {
        let retList = [];

        let inventoryData = [];

        let wareHouse = this.simWareHouseData();

        for (let i = 0; i < wareHouse.length; i++) {
            inventoryData.push(new SubCommodityWarehouseInventoryData({
                warehouseId: wareHouse[i].id,
                subCommodityId: "1",
                count: new CsDouble(Math.floor(Math.random() * 100)),
                storeId: "1",
                warehouseName: wareHouse[i].name,
                storeName: "模拟门店1"
            }))
        }

        //inventoryData = [inventoryData[0]]  // 单个仓库


        retList.push(new SubCommodity({
            id: "1",
            code: "code1",
            name: "短袖",
            qrCode: "qrCode1",
            imgs: "https://img0.baidu.com/it/u=2864706542,2917157997&fm=253&fmt=auto&app=138&f=JPEG",
            standard: "短袖",
            remark: "remark1",
            purchasePrice: 13.3,
            retailPrice: 19.9,
            wholesalePrice: 16.9,
            cost: 12.3,
            inventoryData: inventoryData
        }));

        retList.push(new SubCommodity({
            id: "2",
            code: "code2",
            name: "短裤",
            qrCode: "qrCode2",
            imgs: "",
            standard: "短裤",
            remark: "remark2",
            purchasePrice: 15.3,
            retailPrice: 18.9,
            wholesalePrice: 17.9
        }));

        retList.push(new SubCommodity({
            id: "3",
            code: "code3",
            name: "裙子",
            qrCode: "qrCode2",
            imgs: "",
            standard: "裙子",
            remark: "remark5",
            purchasePrice: 115.3,
            retailPrice: 189.9,
            wholesalePrice: 130.9
        }));

        retList.push(new SubCommodity({
            id: "4",
            code: "code4",
            name: "围巾",
            qrCode: "qrCode3",
            imgs: "",
            standard: "围巾",
            remark: "remark5",
            purchasePrice: 115.3,
            retailPrice: 189.9,
            wholesalePrice: 130.9
        }));

        retList.push(new SubCommodity({
            id: "5",
            code: "code5",
            name: "儿童口罩",
            qrCode: "qrCode5",
            imgs: "",
            standard: "儿童",
            remark: "remark5",
            purchasePrice: 115.3,
            retailPrice: 189.9,
            wholesalePrice: 130.9
        }));

        retList.push(new SubCommodity({
            id: "6",
            code: "code6",
            name: "女士口罩",
            qrCode: "qrCode6",
            imgs: "",
            standard: "成人",
            remark: "remark6",
            purchasePrice: 115.3,
            retailPrice: 189.9,
            wholesalePrice: 130.9
        }));

        retList.push(new SubCommodity({
            id: "7",
            code: "code7",
            name: "袜子",
            qrCode: "qrCode7",
            imgs: "",
            standard: "女士",
            remark: "remark7",
            purchasePrice: 115.3,
            retailPrice: 189.9,
            wholesalePrice: 130.9
        }));

        return retList;
    }

    /// 模拟仓库信息
    simWareHouseData() {
        return [
            new WareHouse({
                id: "1",
                name: "大发路仓库128号,共享仓库3325号,冷链箱体3#-25",
                contactPerson: "王大发",
                contactPhoneNum: "13333333333",
                addr: "大发路xxx号",
                remark: "23232323",
                locked: true,  // 仓库锁定
            }),
            new WareHouse({
                id: "2",
                name: "小路仓库",
                contactPerson: "王晓露",
                contactPhoneNum: "13433333333",
                addr: "小仓路xxx号",
                remark: "23232323"
            }),
            new WareHouse(
                {
                    id: "3",
                    name: "电商仓库",
                    contactPerson: "大哥",
                    contactPhoneNum: "13533333333",
                    addr: "虚拟仓库，对接电商",
                    remark: "23232323"
                }),
        ];
    }

    /// 生成客户模拟数据
    createSimCustomerData() {
        return [
            new Customer({
                id: "1",
                name: "王大发",
                contactName: "王大发",
                contactPhoneNumber: "13888888888",
                email: "dafa@qq.com",
                city: "大发城",
                address: "大发街道223号",
                remark: "优质客户"
            }),
            new Customer({
                id: "2",
                name: "尚云",
                contactName: "李尚允",
                contactPhoneNumber: "13333333333",
                email: "123332@qq.com",
                city: "成都",
                address: "某某街道",
                remark: "潜力客户"
            }),
            new Customer({
                id: "3",
                name: "荣耀",
                contactName: "李荣耀",
                contactPhoneNumber: "13333333333",
                email: "123332@qq.com",
                city: "成都",
                address: "某某街道",
                remark: "潜力客户"
            })
        ];
    }

    /**
 * 生成供应商模拟数据
 * @returns {Array<Supplier>} 供应商列表
 */
    createSimSupplierData() {
        const suList = [];

        suList.push(new Supplier({
            id: "1",
            name: "堂上",
            contactName: "云大上",
            contactPhoneNumber: "13888888888",
            email: "dafa@qq.com",
            city: "上海",
            address: "云街道223号",
            remark: "性价比高"
        }));

        suList.push(new Supplier({
            id: "2",
            name: "牛仔厂",
            contactName: "李销售",
            contactPhoneNumber: "13333333333",
            email: "123332@qq.com",
            city: "成都",
            address: "某某街道",
            remark: "交货慢"
        }));

        suList.push(new Supplier({
            id: "3",
            name: "帽子厂",
            contactName: "毛厂长",
            contactPhoneNumber: "13333333333",
            email: "123332@qq.com",
            city: "成都",
            address: "某某街道",
            remark: "交货慢"
        }));

        return suList;
    }

    /**
 * Simulate inventory in data
 * @param {number|null} orderStatus - 1 for reviewed, 0 for unreviewed
 * @returns {Array<Inventory>} - List of inventory items
 */
    simInventoryInData(orderStatus = null) {
        const list = [];

        if (orderStatus === null || orderStatus === 0) {
            list.push(new Inventory({
                id: "1",
                title: "入库单1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryInTypeData()[0],
                targetObject: this.createSimSupplierData()[0],
                inOutType: InventoryInOutType.In,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    }),
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[1],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(33)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "2",
                title: "入库单2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryInTypeData()[0],
                targetObject: this.createSimSupplierData()[1],
                inOutType: InventoryInOutType.In,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[1],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "3",
                title: "入库单3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryInTypeData()[0],
                targetObject: this.createSimSupplierData()[0],
                inOutType: InventoryInOutType.In,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));
        }

        if (orderStatus === null || orderStatus === 1) {
            list.push(new Inventory({
                id: "4",
                title: "入库单4",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryInTypeData()[0],
                targetObject: this.createSimSupplierData()[0],
                operateDate: new Date(),
                inOutType: InventoryInOutType.In,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "5",
                title: "入库单5",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryInTypeData()[1],
                targetObject: this.createSimSupplierData()[1],
                operateDate: new Date(),
                inOutType: InventoryInOutType.In,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "6",
                title: "入库单6",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryInTypeData()[2],
                targetObject: this.createSimSupplierData()[2],
                operateDate: new Date(),
                inOutType: InventoryInOutType.In,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[2],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));
        }

        return list;
    }

    /**
     * Simulate inventory out data
     * @param {number|null} orderStatus - 1 for reviewed, 0 for unreviewed
     * @returns {Array<Inventory>} - List of inventory items
     */
    simInventoryOutData(orderStatus = null) {
        const list = [];

        if (orderStatus === null || orderStatus === 0) {
            list.push(new Inventory({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryOutTypeData()[0],
                targetObject: this.createSimCustomerData()[0],
                inOutType: InventoryInOutType.Out,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    }),
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[1],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(33)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryOutTypeData()[0],
                targetObject: this.createSimCustomerData()[1],
                inOutType: InventoryInOutType.Out,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[1],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryOutTypeData()[0],
                targetObject: this.createSimCustomerData()[0],
                inOutType: InventoryInOutType.Out,
                operateDate: new Date(),
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));
        }

        if (orderStatus === null || orderStatus === 1) {
            list.push(new Inventory({
                id: "4",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryOutTypeData()[0],
                targetObject: this.createSimCustomerData()[0],
                operateDate: new Date(),
                inOutType: InventoryInOutType.Out,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "5",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryOutTypeData()[1],
                targetObject: this.createSimCustomerData()[1],
                operateDate: new Date(),
                inOutType: InventoryInOutType.Out,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[0],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));

            list.push(new Inventory({
                id: "6",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                status: CommonOrderStatus.Passed,
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryOutTypeData()[2],
                targetObject: this.createSimCustomerData()[2],
                operateDate: new Date(),
                inOutType: InventoryInOutType.Out,
                commodityBatch: [
                    new CommodityBatch({
                        commodity: this.createSimSubCommodityData()[2],
                        count: new CsDouble(2),
                        singlePrice: new CsFundDouble(3),
                        batchPrice: new CsFundDouble(20)
                    })
                ]
            }));
        }

        return list;
    }

    /**
     * 模拟待入库单数据
     * @returns {Array<PendingInventory>} List of pending inventory items
     */
    simPendingInventoryInData() {
        return [
            new PendingInventory({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                docCode: "DRKD123123",
                progressState: ProgressState.None,
                operator: "王大",
                docMaker: "王大",
                recordDate: new Date("2022-01-22 14:32:32"),
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryInTypeData()[0],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimSupplierData()[0],
                inOutType: InventoryInOutType.In,
                parentDocType: DocType.CGD,
                parentDocCode: "CGD123321",
                parentDocTitle: "大灯采购2022",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD123321",
                sourceDocTitle: "大灯采购2022",
                inventoryInList: this.simInventoryInData(null)
            }),
            new PendingInventory({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                docCode: "DRKD321321",
                progressState: ProgressState.PartDone,
                operator: "王二",
                docMaker: "王二",
                recordDate: new Date("2022-02-22 14:32:32"),
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryInTypeData()[1],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimSupplierData()[1],
                inOutType: InventoryInOutType.In,
                parentDocType: DocType.CGD,
                parentDocCode: "CGD12332123",
                parentDocTitle: "小灯采购2022",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD12332123",
                sourceDocTitle: "小灯采购2022",
                inventoryInList: this.simInventoryInData(null)
            }),
            new PendingInventory({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                docCode: "DRKD456654",
                progressState: ProgressState.AllDone,
                operator: "王三",
                docMaker: "王三",
                recordDate: new Date("2022-03-22 14:32:32"),
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryInTypeData()[2],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimSupplierData()[2],
                inOutType: InventoryInOutType.In,
                parentDocType: DocType.CGD,
                parentDocCode: "CGD54345",
                parentDocTitle: "清洗剂采购2022",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD54345",
                sourceDocTitle: "清洗剂采购2022",
                inventoryInList: this.simInventoryInData(null)
            })
        ];
    }

    /**
     * 模拟待出库单数据
     * @returns {Array<PendingInventory>} List of pending inventory items
     */
    simPendingInventoryOutData() {
        return [
            new PendingInventory({
                id: "4",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                docCode: "DCKD123123",
                progressState: ProgressState.None,
                operator: "张大",
                docMaker: "张大",
                recordDate: new Date("2022-02-22 14:32:32"),
                wareHouse: this.simWareHouseData()[0],
                type: this.simInventoryOutTypeData()[0],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimCustomerData()[0],
                inOutType: InventoryInOutType.Out,
                parentDocType: DocType.XSD,
                parentDocCode: "XSD123321",
                parentDocTitle: "大灯销售2022",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD123321",
                sourceDocTitle: "大灯销售2022",
                inventoryInList: this.simInventoryOutData(null)
            }),
            new PendingInventory({
                id: "5",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                docCode: "DCKD321321",
                progressState: ProgressState.PartDone,
                operator: "张二",
                docMaker: "张二",
                recordDate: new Date("2022-02-22 14:32:32"),
                wareHouse: this.simWareHouseData()[1],
                type: this.simInventoryOutTypeData()[1],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimCustomerData()[1],
                inOutType: InventoryInOutType.Out,
                parentDocType: DocType.XSD,
                parentDocCode: "XSD12332123",
                parentDocTitle: "小灯销售2022",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD12332123",
                sourceDocTitle: "小灯销售2022",
                inventoryInList: this.simInventoryOutData(null)
            }),
            new PendingInventory({
                id: "6",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                docCode: "DCKD456654",
                progressState: ProgressState.AllDone,
                operator: "张三",
                docMaker: "张三",
                recordDate: new Date("2022-03-22 14:32:32"),
                wareHouse: this.simWareHouseData()[2],
                type: this.simInventoryOutTypeData()[2],
                commodityList: this.simPendingCommodityBatch(),
                targetObject: this.createSimCustomerData()[2],
                inOutType: InventoryInOutType.Out,
                parentDocType: DocType.XSD,
                parentDocCode: "XSD54345",
                parentDocTitle: "清洗剂采购2022",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD54345",
                sourceDocTitle: "清洗剂销售2022",
                inventoryInList: this.simInventoryOutData(null)
            })
        ];
    }
    /**
     * Generate simulated store data
     * @param {boolean} [withoutEmployeeData=false] - Whether to exclude employee data
     * @returns {Array<Store>} - List of store objects
     */
    simStoreData(withoutEmployeeData = false) {
        const storeList = [];

        storeList.push(new Store({
            id: "1",
            name: "一分店",
            contactPerson: "王大发",
            contactPhoneNum: "13333333333",
            addr: "大发路xxx号",
            remark: "23232323",
            createTime: new Date(2012, 0, 23), // Note: Months are 0-indexed in JS (0 = January)
            employees: withoutEmployeeData
                ? []
                : [
                    new StoreEmployeeRelation({
                        id: "0",
                        store: this.simStoreData(true)[0], // Recursive call with withoutEmployeeData=true
                        employee: this.simEmployeeData()[0]
                    })
                ]
        }));

        storeList.push(new Store({
            id: "2",
            name: "二分店",
            contactPerson: "李达发",
            contactPhoneNum: "13333333335",
            addr: "大发路xxx号",
            createTime: new Date(2015, 2, 24),
            remark: "23232323",
            employees: withoutEmployeeData
                ? []
                : [
                    new StoreEmployeeRelation({
                        id: "0",
                        store: this.simStoreData(true)[0],
                        employee: this.simEmployeeData()[0]
                    }),
                    new StoreEmployeeRelation({
                        id: "1",
                        store: this.simStoreData(true)[1],
                        employee: this.simEmployeeData()[1]
                    })
                ]
        }));

        storeList.push(new Store({
            id: "3",
            name: "三分店",
            contactPerson: "章达发",
            contactPhoneNum: "13333333336",
            addr: "大发路xxx号",
            remark: "23232323",
            createTime: new Date(2018, 7, 4),
            employees: withoutEmployeeData
                ? []
                : [
                    new StoreEmployeeRelation({
                        id: "0",
                        store: this.simStoreData(true)[0],
                        employee: this.simEmployeeData()[0]
                    }),
                    new StoreEmployeeRelation({
                        id: "1",
                        store: this.simStoreData(true)[1],
                        employee: this.simEmployeeData()[1]
                    }),
                    new StoreEmployeeRelation({
                        id: "2",
                        store: this.simStoreData(true)[2],
                        employee: this.simEmployeeData()[2]
                    })
                ]
        }));

        return storeList;
    }


    /**
 * Generate simulated employee data
 * @param {boolean|null} [available] - Filter by available status (null for all)
 * @param {boolean} [withoutStoreEmployeeData=false] - Whether to exclude store employee relations
 * @returns {Array<Employee>} - List of employee objects
 */
    simEmployeeData(available = null, withoutStoreEmployeeData = false) {
        const ret = [];

        if (available === null || available) {
            ret.push(new Employee({
                id: "1",
                name: "李员工",
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0], // withoutEmployeeData=true
                            employee: this.simEmployeeData(null, true)[0] // withoutStoreEmployeeData=true
                        })
                    ]
            }));

            ret.push(new Employee({
                id: "2",
                name: "张员工",
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0],
                            employee: this.simEmployeeData(null, true)[0]
                        })
                    ]
            }));

            ret.push(new Employee({
                id: "3",
                name: "王员工",
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0],
                            employee: this.simEmployeeData(null, true)[0]
                        })
                    ]
            }));
        }

        if (available === null || !available) {
            ret.push(new Employee({
                id: "1",
                name: "郑员工",
                available: false,
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0],
                            employee: this.simEmployeeData(null, true)[0]
                        })
                    ]
            }));

            ret.push(new Employee({
                id: "2",
                name: "启员工",
                available: false,
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0],
                            employee: this.simEmployeeData(null, true)[0]
                        })
                    ]
            }));

            ret.push(new Employee({
                id: "3",
                name: "苏员工",
                available: false,
                role: this.simRoleData(),
                stores: withoutStoreEmployeeData
                    ? []
                    : [
                        new StoreEmployeeRelation({
                            id: "0",
                            store: this.simStoreData(true)[0],
                            employee: this.simEmployeeData(null, true)[0]
                        })
                    ]
            }));
        }

        return ret;
    }

    /**
 * Simulate inventory management permissions
 * @returns {Array<string>} List of permission codes
 */
    simInventoryMgrPermission() {
        const permissionJson = [
            {
                "menuCode": "M_InventoryInMgt",
                "name": "Godown Entry",
                "funCode": "F_InventoryInMgt"
            },
            {
                "menuCode": "M_InventoryOutMgt",
                "name": "Outbound Order",
                "funCode": "F_InventoryOutMgt"
            },
            {
                "menuCode": "M_Inventory_Doc_Check",
                "name": "Inventory Sheet",
                "funCode": "F_InventoryCheck"
            },
            {
                "menuCode": "M_Inventory_Doc_Allocate",
                "name": "Inventory Allocate",
                "funCode": "F_InventoryAllocate"
            }
        ];

        const menuUnitData = [];
        for (const element of permissionJson) {
            menuUnitData.push(element.funCode || "");
        }

        return menuUnitData;
    }

    /**
     * Simulate sales management permissions
     * @returns {Array<string>} List of permission codes
     */
    simSalesMgrPermission() {
        const permissionJson = [
            {
                "menuCode": "M_Sales_Sales_Contract",
                "name": "Sales Contract",
                "funCode": "F_SalesContract"
            },
            {
                "menuCode": "M_Sales_Sales_Return",
                "name": "Sales Return",
                "funCode": "F_SalesReturn"
            }
        ];

        const menuUnitData = [];
        for (const element of permissionJson) {
            menuUnitData.push(element.funCode || "");
        }

        return menuUnitData;
    }

    /**
 * Simulate role data
 * @returns {Array<Role>} List of role objects
 */
    simRoleData() {
        const ret = [];

        ret.push(new Role({
            id: "1",
            name: "管理员",
            remark: "所有权限1 所有权限2所有权限4所有权限6所有权限7所有权限8所有权限9所有权限10",
            fCodeList: []
        }));

        ret.push(new Role({
            id: "2",
            name: "仓库管理员",
            remark: "出入库管理",
            fCodeList: this.simInventoryMgrPermission()
        }));

        ret.push(new Role({
            id: "3",
            name: "销售",
            remark: "销售单管理",
            fCodeList: this.simSalesMgrPermission()
        }));

        ret.push(new Role({
            id: "-1",
            name: "当前用户权限测试角色",
            aPermission: Engine.profile?.permissionMgr
        }));

        return ret;
    }

    /**
 * Simulate inventory in type data
 * @returns {Array<InventoryType>} List of inventory type objects
 */
    simInventoryInTypeData() {
        const list = [];

        list.push(new InventoryType({
            id: "1",
            name: "期初入库",
            code: "r_abc",
            inOutType: InventoryInOutType.In
        }));

        list.push(new InventoryType({
            id: "2",
            name: "采购入库",
            code: "r_bbc",
            inOutType: InventoryInOutType.In
        }));

        list.push(new InventoryType({
            id: "3",
            name: "调拨入库",
            code: "r_cbc",
            inOutType: InventoryInOutType.In
        }));

        // 模拟商户自建出入库类型
        list.push(new InventoryType({
            id: "4",
            name: "盘点入库",
            code: "23456",
            inOutType: InventoryInOutType.In,
            isPlatfromType: false
        }));

        list.push(new InventoryType({
            id: "5",
            name: "销售退货入库",
            code: "123345",
            inOutType: InventoryInOutType.In,
            isPlatfromType: false
        }));

        return list;
    }

    /**
* 模拟出库类型参数
* @returns {Array<InventoryType>} List of inventory type objects
*/
    simInventoryOutTypeData() {
        const list = [];

        list.push(new InventoryType({
            id: "6",
            name: "借调出库",
            code: "c_abc",
            inOutType: InventoryInOutType.Out
        }));

        list.push(new InventoryType({
            id: "7",
            name: "销售出库",
            code: "c_bbc",
            inOutType: InventoryInOutType.Out
        }));

        // 模拟商户自建出入库类型
        list.push(new InventoryType({
            id: "8",
            name: "采购退货出库",
            code: "3245",
            inOutType: InventoryInOutType.Out,
            isPlatfromType: false
        }));

        return list;
    }

    /**
 * Simulate pending inventory commodity batch data
 * @returns {Array<CommodityPendingBatch>} List of pending commodity batches
 */
    simPendingCommodityBatch() {
        return [
            new CommodityPendingBatch({
                id: "1",
                count: new CsDouble(5),
                batchPrice: new CsFundDouble(100),
                singlePrice: new CsFundDouble(20),
                handledCount: new CsDouble(3),
                commodity: this.createSimSubCommodityData()[0]
            }),
            new CommodityPendingBatch({
                id: "2",
                count: new CsDouble(12),
                batchPrice: new CsFundDouble(120),
                singlePrice: new CsFundDouble(10),
                handledCount: new CsDouble(12),
                commodity: this.createSimSubCommodityData()[1]
            }),
            new CommodityPendingBatch({
                id: "3",
                count: new CsDouble(112),
                batchPrice: new CsFundDouble(789),
                singlePrice: new CsFundDouble(10),
                handledCount: new CsDouble(12),
                commodity: this.createSimSubCommodityData()[2]
            })
        ];
    }

    /**
 * 模拟销售单结果
 * @returns {OrderResult} 
 */
    simulateSaleResult() {
        return new OrderResult({
            id: "1",
            commodityCount: new CsDouble(123),
            fundCount: new CsFundDouble(321),
            status: CommonOrderStatus.Passed,
            docType: DocType.XSD,
            parentDocType: DocType.QUOTATION,
            parentDocCode: "11223",
            parentDocTitle: "报价单",
            sourceDocType: DocType.QUOTATION,
            sourceDocCode: "11223",
            sourceDocTitle: "报价单",
            docMaker: "张三",
            operator: "李四",
            operatorId: "1",
            title: "专用商品销售",
            orderResults: [
                new OrderResultCategory({
                    category: OrderResultCategoryType.Fund,
                    items: [
                        new OrderResultCategoryItem({
                            itemName: "客户A",
                            itemId: "123",
                            type: OrderResultCategoryItemType.ReceiveDebt,
                            countBefore: 0,
                            countAfter: 100,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "供应商B",
                            itemId: "123",
                            type: OrderResultCategoryItemType.PaymentDebt,
                            countBefore: 0,
                            countAfter: 100,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "账户A",
                            itemId: "123",
                            type: OrderResultCategoryItemType.FundAccount,
                            countBefore: 101,
                            countAfter: 201,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "预收账户",
                            itemId: "123",
                            type: OrderResultCategoryItemType.PreReceiveAccount,
                            countBefore: 301,
                            countAfter: 201,
                            count: -100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "预付账户",
                            itemId: "123",
                            type: OrderResultCategoryItemType.PrePaymentAccount,
                            countBefore: 401,
                            countAfter: 301,
                            count: -100,
                        })
                    ],
                }),
                new OrderResultCategory({
                    category: OrderResultCategoryType.Inventory,
                    items: [
                        new OrderResultCategoryItem({
                            itemName: "商品1",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 0,
                            countAfter: 100,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品2",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 100,
                            countAfter: 90,
                            count: -10,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品3",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 200,
                            countAfter: 180,
                            count: -20,
                        }),
                    ],
                }),
                new OrderResultCategory({
                    category: OrderResultCategoryType.PendingInventoryIn,
                    items: [
                        new OrderResultCategoryItem({
                            itemName: "商品1",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 0,
                            countAfter: 100,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品2",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 100,
                            countAfter: 90,
                            count: -10,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品3",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 200,
                            countAfter: 180,
                            count: -20,
                        }),
                    ],
                }),
                new OrderResultCategory({
                    category: OrderResultCategoryType.PendingInventoryOut,
                    items: [
                        new OrderResultCategoryItem({
                            itemName: "商品1",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 0,
                            countAfter: 100,
                            count: 100,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品2",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 100,
                            countAfter: 90,
                            count: -10,
                        }),
                        new OrderResultCategoryItem({
                            itemName: "商品3",
                            itemId: "123",
                            type: OrderResultCategoryItemType.CommodityInventory,
                            countBefore: 200,
                            countAfter: 180,
                            count: -20,
                        }),
                    ],
                })
            ]
        });
    }

    /**
 * 模拟库存信息
 * Simulate inventory information
 * @returns {Array<SubCommodityInventorySumData>} List of inventory summary data
 */
    simSubCommodityInventorySumData() {
        return [
            new SubCommodityInventorySumData({
                subCommodity: this.createSimSubCommodityData()[0],
                singleCost: 12,
                totalCost: 120,
                availableCount: 10,
                waitInCount: 3,
                waitOutCount: 2,
                totalInventoryCount: 12
            }),
            new SubCommodityInventorySumData({
                subCommodity: this.createSimSubCommodityData()[1],
                singleCost: 15,
                totalCost: 170,
                availableCount: 11,
                waitInCount: 2,
                waitOutCount: 7,
                totalInventoryCount: 18
            }),
            new SubCommodityInventorySumData({
                subCommodity: this.createSimSubCommodityData()[2],
                singleCost: 110,
                totalCost: 1700,
                availableCount: 11,
                waitInCount: 2,
                waitOutCount: 7,
                totalInventoryCount: 18
            })
        ];
    }

    /**
 * 模拟组装拆卸单
 * Simulate inventory assembler data
 * @param {number|null} orderStatus - 1 for reviewed, 0 for unreviewed
 * @returns {Array<InventoryAssembler>} - List of inventory assembler items
 */
    simInventoryAssemblerData(orderStatus = null) {
        const list = [];

        if (orderStatus === null || orderStatus === 0) {
            list.push(new InventoryAssembler({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                srcWareHouse: this.simWareHouseData()[0],
                targetWareHouse: this.simWareHouseData()[1],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                operator: "库管王",
                docMaker: "王大",
                title: "临时借调",
                cost: 0
            }));

            list.push(new InventoryAssembler({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                srcWareHouse: this.simWareHouseData()[1],
                targetWareHouse: this.simWareHouseData()[2],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                operator: "库管李",
                docMaker: "王大",
                title: "店铺之间组装拆卸",
                cost: 0
            }));

            list.push(new InventoryAssembler({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                srcWareHouse: this.simWareHouseData()[2],
                targetWareHouse: this.simWareHouseData()[0],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                operator: "库管郑",
                docMaker: "王大",
                title: "租借组装拆卸",
                cost: 0
            }));
        }

        if (orderStatus === null || orderStatus === 1) {
            list.push(new InventoryAssembler({
                id: "4",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                srcWareHouse: this.simWareHouseData()[0],
                targetWareHouse: this.simWareHouseData()[1],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                status: CommonOrderStatus.Passed,
                operator: "库管王大",
                docMaker: "王大",
                title: "临时借调",
                cost: 0
            }));

            list.push(new InventoryAssembler({
                id: "5",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                srcWareHouse: this.simWareHouseData()[1],
                targetWareHouse: this.simWareHouseData()[0],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                status: CommonOrderStatus.Passed,
                operator: "库管李二",
                docMaker: "王大",
                title: "店铺之间组装拆卸",
                cost: 0
            }));

            list.push(new InventoryAssembler({
                id: "6",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                srcWareHouse: this.simWareHouseData()[2],
                targetWareHouse: this.simWareHouseData()[1],
                orgCommodityBatch: this.simCommodityBatch(),
                newCommodityBatch: this.simCommodityBatch(),
                status: CommonOrderStatus.Passed,
                operator: "库管郑三",
                docMaker: "王大",
                title: "租借组装拆卸",
                cost: 0
            }));
        }

        return list;
    }

    /**
 * 模拟盘点商品
 * @returns {Array<CommodityBatchSheet>} List of commodity batch sheets
 */
    simCommodityBatchSheet() {
        return [
            new CommodityBatchSheet({
                commodity: this.createSimSubCommodityData()[0],
                count: new CsDouble(2),
                adjustCount: new CsDouble(3),
            }),
            new CommodityBatchSheet({
                commodity: this.createSimSubCommodityData()[1],
                count: new CsDouble(2),
            }),
            new CommodityBatchSheet({
                commodity: this.createSimSubCommodityData()[2],
                count: new CsDouble(2),
                adjustCount: new CsDouble(1),
            })
        ];
    }

    /**
     * 模拟盘点单
     * @param {number|null} orderStatus - 1 for reviewed, 0 for unreviewed
     * @returns {Array<InventorySheet>} List of inventory sheet items
     */
    simInventorySheetData(orderStatus = null) {
        const list = [];

        if (orderStatus === null || orderStatus === 0) {
            list.push(new InventorySheet({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                wareHouse: this.simWareHouseData()[0],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点王",
                docMaker: "王大",
                title: "月中盘点1月中盘点2月中盘点3月中盘点4月中盘点6",
                status: CommonOrderStatus.WaitReview,
                fromEmtyConstructor: true
            }));

            list.push(new InventorySheet({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                wareHouse: this.simWareHouseData()[1],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点李",
                docMaker: "王大",
                title: "月底盘点",
                status: CommonOrderStatus.WaitReview,
                fromEmtyConstructor: true
            }));

            list.push(new InventorySheet({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                wareHouse: this.simWareHouseData()[1],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点正",
                docMaker: "王大",
                title: "年末盘点",
                status: CommonOrderStatus.WaitReview,
                fromEmtyConstructor: true
            }));
        }

        if (orderStatus === null || orderStatus === 1) {
            list.push(new InventorySheet({
                id: "4",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                wareHouse: this.simWareHouseData()[0],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点云",
                docMaker: "王大",
                title: "清仓盘点",
                status: CommonOrderStatus.Passed,
                fromEmtyConstructor: true
            }));

            list.push(new InventorySheet({
                id: "5",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                wareHouse: this.simWareHouseData()[1],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点邓",
                docMaker: "王大",
                title: "交接盘点",
                status: CommonOrderStatus.Passed,
                fromEmtyConstructor: true
            }));

            list.push(new InventorySheet({
                id: "6",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                wareHouse: this.simWareHouseData()[1],
                commodityBatch: this.simCommodityBatchSheet(),
                operator: "盘点秦",
                docMaker: "王大",
                title: "年中盘点",
                status: CommonOrderStatus.Passed,
                fromEmtyConstructor: true
            }));
        }

        return list;
    }

    /**
 * 模拟出入库明细
 * Simulate all inventory in/out records
 * @returns {Array<InventoryInOutRecord>} List of inventory in/out records
 */
    simAllInventoryInOutRecordData() {
        return [
            new InventoryInOutRecord({
                creator: "王大",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[0],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(3),
                    batchPrice: new CsFundDouble(20)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.In,
                createTime: "2022-04-04",
                id: ""
            }),
            new InventoryInOutRecord({
                creator: "王二",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[1],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(3),
                    batchPrice: new CsFundDouble(20)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.Out,
                createTime: "2022-04-03",
                id: ""
            }),
            new InventoryInOutRecord({
                creator: "王三",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[1],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(5),
                    batchPrice: new CsFundDouble(50)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.Out,
                createTime: "2022-04-03",
                id: ""
            })
        ];
    }

    /**
     * 模拟入库明细
     * Simulate inventory in records
     * @returns {Array<InventoryInOutRecord>} List of inventory in records
     */
    simInventoryInRecordData() {
        return [
            new InventoryInOutRecord({
                creator: "王大",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[0],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(3),
                    batchPrice: new CsFundDouble(20)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.In,
                createTime: "2022-04-04",
                id: ""
            })
        ];
    }

    /**
     * 模拟出库明细
     * Simulate inventory out records
     * @returns {Array<InventoryInOutRecord>} List of inventory out records
     */
    simInventoryOutRecordData() {
        return [
            new InventoryInOutRecord({
                creator: "王二",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[1],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(3),
                    batchPrice: new CsFundDouble(20)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.Out,
                createTime: "2022-04-03",
                id: ""
            }),
            new InventoryInOutRecord({
                creator: "王三",
                commodityBatch: new CommodityBatch({
                    commodity: this.createSimSubCommodityData()[1],
                    count: new CsDouble(2),
                    singlePrice: new CsFundDouble(5),
                    batchPrice: new CsFundDouble(50)
                }),
                wareHouse: this.simWareHouseData()[0],
                type: InventoryInOutType.Out,
                createTime: "2022-04-03",
                id: ""
            })
        ];
    }

    /**
 * 模拟销售信息
 * @param {CommonOrderStatus|null} state - 订单状态过滤条件
 * @returns {Array<SalesContract>} 销售合同列表
 */
    simSalesContractData(state = null) {
        const list = [];

        if (state === null || state.code === CommonOrderStatus.Passed.code) {
            list.push(new SalesContract({
                id: "1",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                title: "销售单1",
                targetObject: this.createSimCustomerData()[0],
                wareHouse: this.simWareHouseData()[0],
                salesDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "王销售",
                docMaker: "王销售",
                recordDate: new Date("2022-03-23"),
                remark: "这是测试销售单1",
                otherCost: 12,
                discout: 2,
                payedMount: 3,
                status: CommonOrderStatus.Passed,
                inventory: this.simPendingInventoryOutData()[0],
                receiveOrder: this.simPendingReceiveOrder(null)[0],
            }));

            list.push(new SalesContract({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                title: "销售单2",
                targetObject: this.createSimCustomerData()[1],
                wareHouse: this.simWareHouseData()[1],
                salesDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "李销售",
                docMaker: "李销售",
                recordDate: new Date("2022-03-23"),
                remark: "这是测试销售单2",
                otherCost: 12,
                discout: 2,
                payedMount: 3,
                status: CommonOrderStatus.Passed,
                inventory: this.simPendingInventoryOutData()[1],
                receiveOrder: this.simPendingReceiveOrder(null)[1],
            }));
        }

        if (state === null || state === CommonOrderStatus.WaitReview) {
            list.push(new SalesContract({
                id: "3",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                title: "销售单3",
                targetObject: this.createSimCustomerData()[2],
                wareHouse: this.simWareHouseData()[2],
                salesDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "正销售",
                docMaker: "正销售",
                recordDate: new Date("2022-03-23"),
                remark: "这是测试销售单3",
                otherCost: 12,
                discout: 2,
                payedMount: 3,
                status: CommonOrderStatus.WaitReview,
                inventory: this.simPendingInventoryOutData()[2],
                receiveOrder: this.simPendingReceiveOrder(null)[2],
            }));
        }

        return list;
    }

    /**
 * 模拟采购单
 * @param {CommonOrderStatus|null} state - 订单状态过滤条件
 * @returns {Array<PurchaseContract>} 采购合同列表
 */
    simStatePurchaseContractData(state = null) {
        const list = [];

        if (state === null || state.code === CommonOrderStatus.Passed.code) {
            list.push(new PurchaseContract({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                title: "采购单1",
                supplier: this.createSimSupplierData()[0],
                wareHouse: this.simWareHouseData()[0],
                purchaseDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "王大",
                docMaker: "王大",
                recordDate: new Date("2022-03-23"),
                remark: "这是测试采购单1",
                otherCost: 12,
                discout: 2,
                payedMount: 3,
                status: CommonOrderStatus.Passed,
                inventory: this.simPendingInventoryInData()[0],
                paymentOrder: this.simPendingPaymentOrder(null)[0],
            }));

            list.push(new PurchaseContract({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                title: "采购单2",
                supplier: this.createSimSupplierData()[1],
                wareHouse: this.simWareHouseData()[1],
                purchaseDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "王二",
                docMaker: "王二",
                recordDate: new Date("2022-03-24"),
                remark: "这是测试采购单2",
                status: CommonOrderStatus.Passed,
                inventory: this.simPendingInventoryInData()[1],
                paymentOrder: this.simPendingPaymentOrder(null)[1],
            }));
        }

        if (state === null || state.code === CommonOrderStatus.WaitReview.code) {
            list.push(new PurchaseContract({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                title: "采购单3",
                supplier: this.createSimSupplierData()[2],
                wareHouse: this.simWareHouseData()[2],
                purchaseDate: new Date(),
                commmodityList: this.simSalesCommodityBatch(),
                operator: "王三",
                docMaker: "王三",
                recordDate: new Date("2022-03-25"),
                remark: "这是测试采购单3",
                status: CommonOrderStatus.WaitReview,
                inventory: this.simPendingInventoryInData()[2],
                paymentOrder: this.simPendingPaymentOrder(null)[2],
            }));
        }

        return list;
    }

    /**
 * 模拟资金账户
 * @returns {Array<FundAccount>} List of fund account objects
 */
    simFundAccount() {
        return [
            new FundAccount({
                id: "1",
                name: "总账",
                balance: 12345,
                income: 54321,
                expenses: 23451
            }),
            new FundAccount({
                id: "2",
                name: "一分店",
                balance: 45678,
                income: 76543,
                expenses: 31223
            }),
            new FundAccount({
                id: "3",
                name: "微信",
                balance: 56789,
                income: 86543,
                expenses: 30223
            })
        ];
    }

    /**
  * 模拟付款单,待审核
  * @param {Array<PendingReceiveOrder>|null} curPendingOrder - Current pending orders
  * @returns {Array<ReceiveOrder>} List of receive order objects
  */
    simReceiveOrder(curPendingOrder = null) {
        const receiveOrders = [
            new ReceiveOrder({
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                targetObject: this.createSimSupplierData()[0],
                pendingReceiveOrderList: [],
                disCount: 1,
                operator: "财务王",
                title: "灯具收款",
                date: new Date(),
                fundType: ReceiveFundType.XSSK,
                id: "1"
            }),
            new ReceiveOrder({
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                targetObject: this.createSimSupplierData()[1],
                pendingReceiveOrderList: [],
                disCount: 1,
                title: "燃具收款",
                operator: "收银王",
                date: new Date(),
                fundType: ReceiveFundType.XSSK,
                id: "2"
            }),
            new ReceiveOrder({
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                targetObject: this.createSimSupplierData()[2],
                pendingReceiveOrderList: [],
                disCount: 1,
                title: "厨具收款",
                operator: "王店员",
                date: new Date(),
                fundType: ReceiveFundType.XSSK,
                id: "3"
            })
        ];

        const pendingReceiveOrders = curPendingOrder || this.simPendingReceiveOrder(receiveOrders);

        const pendingPaymentOrderList = [
            new PendingReceiveOrderRelation({
                id: "",
                pendingOrder: pendingReceiveOrders[0],
                hexiaoAmount: 100,
                receiveOrder: receiveOrders[0]
            }),
            new PendingReceiveOrderRelation({
                id: "",
                pendingOrder: pendingReceiveOrders[1],
                hexiaoAmount: 120,
                receiveOrder: receiveOrders[1]
            }),
            new PendingReceiveOrderRelation({
                id: "",
                pendingOrder: pendingReceiveOrders[2],
                hexiaoAmount: 130,
                receiveOrder: receiveOrders[2]
            })
        ];

        for (const element of receiveOrders) {
            element.updatePendingReceiveOrderList(pendingPaymentOrderList);
        }

        return receiveOrders;
    }

    /**
     * 模拟待付款单
     * @param {Array<ReceiveOrder>|null} curOder - Current orders
     * @returns {Array<PendingReceiveOrder>} List of pending receive order objects
     */
    simPendingReceiveOrder(curOder = null) {
        const pendingReceiveOrder = [
            new PendingReceiveOrder({
                targetObject: this.createSimSupplierData()[0],
                progressState: ProgressState.None,
                totalMount: 123,
                receiveRelationOrderList: [],
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                remark: "",
                operator: "王大",
                docMaker: "王大",
                docCode: "YSKD123",
                parentDocType: DocType.XSD,
                parentDocCode: "XSD321",
                parentDocTitle: "销售灯具，厨具共计252件",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD321",
                sourceDocTitle: "销售灯具，厨具共计252件",
                recordDate: new Date()
            }),
            new PendingReceiveOrder({
                targetObject: this.createSimSupplierData()[1],
                progressState: ProgressState.PartDone,
                totalMount: 12345,
                receiveRelationOrderList: [],
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                remark: "",
                operator: "王二",
                docMaker: "王二",
                docCode: "YSKD3123",
                parentDocType: DocType.XSD,
                parentDocCode: "XSD3321",
                parentDocTitle: "销售衣服",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD3321",
                sourceDocTitle: "销售衣服",
                recordDate: new Date()
            }),
            new PendingReceiveOrder({
                targetObject: this.createSimSupplierData()[1],
                progressState: ProgressState.PartDone,
                totalMount: 12345,
                receiveRelationOrderList: [],
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                remark: "",
                operator: "王三",
                docMaker: "王三",
                docCode: "YSKD4123",
                parentDocType: DocType.XSD,
                parentDocCode: "XSD4321",
                parentDocTitle: "销售桌子",
                sourceDocType: DocType.XSD,
                sourceDocCode: "XSD4321",
                sourceDocTitle: "销售桌子",
                recordDate: new Date()
            })
        ];

        const receiveOrder = curOder || this.simReceiveOrder(pendingReceiveOrder);

        const relationList = [];
        relationList.push(new PendingReceiveOrderRelation({
            id: "1",
            pendingOrder: pendingReceiveOrder[0],
            receiveOrder: receiveOrder[0],
            hexiaoAmount: 100
        }));

        relationList.push(new PendingReceiveOrderRelation({
            id: "2",
            pendingOrder: pendingReceiveOrder[1],
            receiveOrder: receiveOrder[0],
            hexiaoAmount: 110
        }));

        relationList.push(new PendingReceiveOrderRelation({
            id: "3",
            pendingOrder: pendingReceiveOrder[2],
            receiveOrder: receiveOrder[0],
            hexiaoAmount: 120
        }));

        for (const element of pendingReceiveOrder) {
            element.updateReceiveList(relationList);
        }

        return pendingReceiveOrder;
    }

    /**
 * 模拟付款单,待审核
 * @param {Array<PendingPaymentOrder>|null} curPendingOrder - Current pending orders
 * @returns {Array<PaymentOrder>} List of payment order objects
 */
    simPaymentOrder(curPendingOrder = null) {
        const paymentOrders = [
            new PaymentOrder({
                targetObject: this.createSimSupplierData()[0],
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                operator: "王大",
                title: "灯具付款",
                fundType: PaymentFundType.CGFK,
                id: "1"
            }),
            new PaymentOrder({
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                targetObject: this.createSimSupplierData()[1],
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                title: "燃具付款",
                operator: "王二",
                fundType: PaymentFundType.CGFK,
                id: "2"
            }),
            new PaymentOrder({
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                targetObject: this.createSimSupplierData()[2],
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                title: "厨具付款",
                operator: "王三",
                fundType: PaymentFundType.CGFK,
                id: "3"
            })
        ];

        const pendingPaymentOrders = curPendingOrder || this.simPendingPaymentOrder(paymentOrders);

        const pendingPaymentOrderList = [
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[0],
                hexiaoAmount: 100,
                paymentOrder: paymentOrders[0]
            }),
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[1],
                hexiaoAmount: 120,
                paymentOrder: paymentOrders[1]
            }),
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[2],
                hexiaoAmount: 130,
                paymentOrder: paymentOrders[2]
            }),
        ];

        for (const element of paymentOrders) {
            element.updatePendingPaymentOrderList(pendingPaymentOrderList);
        }

        return paymentOrders;
    }

    /**
     * 模拟已审核单
     * @param {Array<PendingPaymentOrder>|null} curPendingOrder - Current pending orders
     * @returns {Array<PaymentOrder>} List of reviewed payment order objects
     */
    simReviewedPaymentOrder(curPendingOrder = null) {
        const paymentOrders = [
            new PaymentOrder({
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                targetObject: this.createSimSupplierData()[0],
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                operator: "正大",
                title: "衣服付款",
                status: CommonOrderStatus.Passed,
                fundType: PaymentFundType.CGFK,
                id: "4"
            }),
            new PaymentOrder({
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                targetObject: this.createSimSupplierData()[1],
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                operator: "正二",
                title: "裤子付款",
                status: CommonOrderStatus.Passed,
                fundType: PaymentFundType.CGFK,
                id: "5"
            }),
            new PaymentOrder({
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                targetObject: this.createSimSupplierData()[2],
                date: new Date(),
                pendingPaymentOrderList: [],
                disCount: 1,
                operator: "正三",
                title: "帽子付款",
                status: CommonOrderStatus.Passed,
                fundType: PaymentFundType.CGFK,
                id: "6"
            })
        ];

        const pendingPaymentOrders = curPendingOrder || this.simPendingPaymentOrder(paymentOrders);

        const pendingPaymentOrderList = [
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[0],
                hexiaoAmount: 100,
                paymentOrder: paymentOrders[0]
            }),
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[1],
                hexiaoAmount: 120,
                paymentOrder: paymentOrders[1]
            }),
            new PendingPaymentOrderRelation({
                id: "",
                pendingOrder: pendingPaymentOrders[2],
                hexiaoAmount: 130,
                paymentOrder: paymentOrders[2]
            }),
        ];

        for (const element of paymentOrders) {
            element.updatePendingPaymentOrderList(pendingPaymentOrderList);
        }

        return paymentOrders;
    }

    /**
     * 模拟待付款单
     * @param {Array<PaymentOrder>|null} curOder - Current orders
     * @returns {Array<PendingPaymentOrder>} List of pending payment order objects
     */
    simPendingPaymentOrder(curOder = null) {
        const pendingPaymentOrder = [
            new PendingPaymentOrder({
                targetObject: this.createSimSupplierData()[0],
                progressState: ProgressState.None,
                totalMount: 123,
                paymentRelationOrderList: [],
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                remark: "",
                operator: "王大",
                docMaker: "王大",
                docCode: "DFKD123",
                parentDocType: DocType.CGD,
                parentDocCode: "CGD321",
                parentDocTitle: "采购灯具",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD321",
                sourceDocTitle: "采购灯具",
                recordDate: new Date(),
            }),
            new PendingPaymentOrder({
                targetObject: this.createSimSupplierData()[1],
                progressState: ProgressState.PartDone,
                totalMount: 12345,
                paymentRelationOrderList: [],
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                remark: "",
                operator: "王二",
                docMaker: "王二",
                docCode: "DFKD3123",
                parentDocType: DocType.CGD,
                parentDocCode: "CGD3321",
                parentDocTitle: "采购衣服夏季服装，上衣，裙子等18件",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD3321",
                sourceDocTitle: "采购衣服夏季服装，上衣，裙子等18件",
                recordDate: new Date(),
            }),
            new PendingPaymentOrder({
                targetObject: this.createSimSupplierData()[1],
                progressState: ProgressState.PartDone,
                totalMount: 12345,
                paymentRelationOrderList: [],
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                remark: "",
                operator: "王三",
                docMaker: "王三",
                docCode: "DFKD4123",
                parentDocType: DocType.CGD,
                parentDocCode: "CGD4321",
                parentDocTitle: "采购桌子",
                sourceDocType: DocType.CGD,
                sourceDocCode: "CGD4321",
                sourceDocTitle: "采购桌子",
                recordDate: new Date(),
            }),
        ];

        const paymentOrder = curOder || this.simPaymentOrder(pendingPaymentOrder);

        const relationList = [];

        relationList.push(new PendingPaymentOrderRelation({
            id: "1",
            pendingOrder: pendingPaymentOrder[0],
            paymentOrder: paymentOrder[0],
            hexiaoAmount: 100
        }));

        relationList.push(new PendingPaymentOrderRelation({
            id: "2",
            pendingOrder: pendingPaymentOrder[1],
            paymentOrder: paymentOrder[0],
            hexiaoAmount: 110
        }));

        relationList.push(new PendingPaymentOrderRelation({
            id: "3",
            pendingOrder: pendingPaymentOrder[2],
            paymentOrder: paymentOrder[0],
            hexiaoAmount: 120
        }));

        for (const element of pendingPaymentOrder) {
            element.updatePaymentList(relationList);
        }

        return pendingPaymentOrder;
    }

    /**
 * 模拟委外加工合同数据
 * @param {CommonOrderStatus|null} state - 订单状态过滤条件
 * @returns {Array<MetalRefiningContract>} 委外加工合同列表
 */
    simStateMetalRefiningContractData(state = null) {
        const list = [];

        if (state === null || state.code === ContractManufacturingStatus.Finished.code) {
            list.push(new MetalRefiningContract({
                id: "1",
                storeId: this.simStoreData()[0].id,
                storeName: this.simStoreData()[0].name,
                title: "委外加工合同1",
                supplier: this.createSimSupplierData()[0],
                srcWareHouse: this.simWareHouseData()[0],
                targetWareHouse: this.simWareHouseData()[1],
                orderDate: new Date(),
                commodity: this.simMentalRefiningBatch(),
                operator: "王大",
                docMaker: "王大",
                recordDate: new Date("2022-03-23"),
                remark: "这是测试委外加工合同1",
                otherCost: new CsFundDouble(12),
                discout: new CsFundDouble(2),
                payedMount: new CsFundDouble(3),
                status: ContractManufacturingStatus.Finished,
                inventory: this.simPendingInventoryOutData()[0],
                paymentOrder: this.simPendingPaymentOrder(null)[0],
            }));

            list.push(new MetalRefiningContract({
                id: "2",
                storeId: this.simStoreData()[1].id,
                storeName: this.simStoreData()[1].name,
                title: "委外加工合同2",
                supplier: this.createSimSupplierData()[1],
                srcWareHouse: this.simWareHouseData()[1],
                targetWareHouse: this.simWareHouseData()[2],
                orderDate: new Date(),
                commodity: this.simMentalRefiningBatch(),
                operator: "王二",
                docMaker: "王二",
                recordDate: new Date("2022-03-24"),
                remark: "这是测试委外加工合同2",
                status: ContractManufacturingStatus.Finished,
                inventory: this.simPendingInventoryOutData()[1],
                paymentOrder: this.simPendingPaymentOrder(null)[1],
            }));
        }

        if (state === null || state.code === ContractManufacturingStatus.Working.code) {
            list.push(new MetalRefiningContract({
                id: "3",
                storeId: this.simStoreData()[2].id,
                storeName: this.simStoreData()[2].name,
                title: "委外加工合同3",
                supplier: this.createSimSupplierData()[2],
                srcWareHouse: this.simWareHouseData()[2],
                targetWareHouse: this.simWareHouseData()[0],
                orderDate: new Date(),
                commodity: this.simMentalRefiningBatch(),
                operator: "王三",
                docMaker: "王三",
                recordDate: new Date("2022-03-25"),
                remark: "这是测试委外加工合同3",
                status: ContractManufacturingStatus.Working,
                inventory: this.simPendingInventoryOutData()[2],
                paymentOrder: this.simPendingPaymentOrder(null)[2],
            }));
        }

        return list;
    }

    /**
     * 模拟委外加工批次数据
     * @returns {Array<MentalRefiningBatch>} 委外加工批次列表
     */
    simMentalRefiningBatch() {
        return [
            new MentalRefiningBatch({
                commodity: this.createSimSubCommodityData()[0],
                count: new CsDouble(2),
                singlePrice: new CsFundDouble(3),
                batchPrice: new CsFundDouble(20),
                meltWeight: new CsDouble(0.8),
                usage: new CsDouble(1.5),
                shouldReturn: new CsDouble(1.4),
                realReturn: new CsDouble(1.6),
                profitLoss: new CsDouble(0.1),
                deviation: new CsDouble(0.2),
                meltLoss: new CsDouble(0.25),
                grade: new CsDouble(1.066666667),
                loss: new CsDouble(0.05)
            }),
            new MentalRefiningBatch({
                commodity: this.createSimSubCommodityData()[1],
                count: new CsDouble(3),
                singlePrice: new CsFundDouble(5),
                batchPrice: new CsFundDouble(30),
                meltWeight: new CsDouble(1.2),
                usage: new CsDouble(2.0),
                shouldReturn: new CsDouble(1.8),
                realReturn: new CsDouble(2.1),
                profitLoss: new CsDouble(0.1),
                deviation: new CsDouble(0.3),
                meltLoss: new CsDouble(0.3333),
                grade: new CsDouble(1.05),
                loss: new CsDouble(0.0333)
            }),
            new MentalRefiningBatch({
                commodity: this.createSimSubCommodityData()[2],
                count: new CsDouble(1),
                singlePrice: new CsFundDouble(10),
                batchPrice: new CsFundDouble(10),
                meltWeight: new CsDouble(0.5),
                usage: new CsDouble(0.8),
                shouldReturn: new CsDouble(0.7),
                realReturn: new CsDouble(0.9),
                profitLoss: new CsDouble(0.1),
                deviation: new CsDouble(0.2),
                meltLoss: new CsDouble(0.2),
                grade: new CsDouble(1.125),
                loss: new CsDouble(0.1)
            })
        ];
    }

    /**
     * 模拟金属综合单据数据
     * @param {CommonOrderStatus|null} state - 订单状态过滤条件
     * @returns {Array<MetalCombineOrder>} 金属综合单据列表
     */
    simMetalCombineOrder() {
        const list = [];
        list.push(new MetalCombineOrder({
            id: "1",
            storeId: this.simStoreData()[0].id,
            storeName: this.simStoreData()[0].name,
            title: "金属综合单据1",
            targetObject: this.createSimCustomerData()[0],
            wareHouse: this.simWareHouseData()[0],
            operator: "王大",
            docMaker: "王大",
            recordDate: new Date("2022-03-23"),
            remark: "这是测试金属综合单据1",
            status: CommonOrderStatus.Passed,
            salesCommodities: this.simSalesCommodityBatch(),
            purchaseCommodities: this.simSalesCommodityBatch(),
            receiveableAmount: new CsFundDouble(5000),
            payableAmount: new CsFundDouble(3000),
            receivedAmount: new CsFundDouble(5000),
            paymentAmount: new CsFundDouble(3000),
            fundAccount: this.simFundAccount()[0],
        }));

        list.push(new MetalCombineOrder({
            id: "2",
            storeId: this.simStoreData()[1].id,
            storeName: this.simStoreData()[1].name,
            title: "金属综合单据2",
            targetObject: this.createSimCustomerData()[1],
            wareHouse: this.simWareHouseData()[1],
            operator: "王二",
            docMaker: "王二",
            recordDate: new Date("2022-03-24"),
            remark: "这是测试金属综合单据2",
            status: CommonOrderStatus.Passed,
            salesCommodities: this.simSalesCommodityBatch(),
            purchaseCommodities: this.simSalesCommodityBatch(),
            receiveableAmount: new CsFundDouble(8000),
            payableAmount: new CsFundDouble(5000),
            receivedAmount: new CsFundDouble(8000),
            paymentAmount: new CsFundDouble(5000),
            fundAccount: this.simFundAccount()[1],
        }));



        list.push(new MetalCombineOrder({
            id: "3",
            storeId: this.simStoreData()[2].id,
            storeName: this.simStoreData()[2].name,
            title: "金属综合单据3",
            targetObject: this.createSimCustomerData()[2],
            wareHouse: this.simWareHouseData()[2],
            operator: "王三",
            docMaker: "王三",
            recordDate: new Date("2022-03-25"),
            remark: "这是测试金属综合单据3",
            status: CommonOrderStatus.Passed,
            salesCommodities: this.simSalesCommodityBatch(),
            purchaseCommodities: this.simSalesCommodityBatch(),
            receiveableAmount: new CsFundDouble(6000),
            payableAmount: new CsFundDouble(4000),
            receivedAmount: new CsFundDouble(6000),
            paymentAmount: new CsFundDouble(4000),
            fundAccount: this.simFundAccount()[2],
        }));


        return list;
    }

    /**
     * 模拟销售商品批次数据
     * @returns {Array<CommodityBatchWithTax>} 销售商品批次列表
     */
    simSalesCommodityBatch() {
        return [
            new CommodityBatchWithTax({
                commodity: this.createSimSubCommodityData()[0],
                count: new CsDouble(5),
                singlePrice: new CsFundDouble(1000),
                batchPrice: new CsFundDouble(5000),
                discount: new CsDouble(100),
                taxRate: new CsDouble(13),
                isPromotional: false
            }),
            new CommodityBatchWithTax({
                commodity: this.createSimSubCommodityData()[1],
                count: new CsDouble(3),
                singlePrice: new CsFundDouble(800),
                batchPrice: new CsFundDouble(2400),
                discount: new CsDouble(95),
                taxRate: new CsDouble(13),
                isPromotional: false
            }),
            new CommodityBatchWithTax({
                commodity: this.createSimSubCommodityData()[2],
                count: new CsDouble(2),
                singlePrice: new CsFundDouble(1500),
                batchPrice: new CsFundDouble(3000),
                discount: new CsDouble(100),
                taxRate: new CsDouble(13),
                isPromotional: false
            })
        ];
    }

    /**
     * 模拟结算单
     * @returns {Array<PeriodSettlementOrder>} 
     */
    simPeriodSettlementOrder() {
        const list = [];
        list.push(new PeriodSettlementOrder({
            id: "1",
            storeId: this.simStoreData()[0].id,
            storeName: this.simStoreData()[0].name,
            title: "结算单1",
            operator: "王大",
            docMaker: "王大",
            recordDate: new Date("2022-03-23"),
        }))
        list.push(new PeriodSettlementOrder({
            id: "2",
            storeId: this.simStoreData()[1].id,
            storeName: this.simStoreData()[1].name,
            title: "结算单2",
            operator: "王二",
            docMaker: "王二",
            recordDate: new Date("2022-03-24"),
        }))
        list.push(new PeriodSettlementOrder({
            id: "3",
            storeId: this.simStoreData()[2].id,
            storeName: this.simStoreData()[2].name,
            title: "结算单3",
            operator: "王三",
            docMaker: "王三",
            recordDate: new Date("2022-03-25"),
        }));
    }

        /**
     * 模拟金属综合单据数据
     * @param {CommonOrderStatus|null} state - 订单状态过滤条件
     * @returns {Array<Customer>} 金属综合单据列表
     */
    simCustomersMetalBalances() {
        let customerList = this.createSimCustomerData();

        // 没有模拟贵金属账户类型，因为每个商户不一样，后期模拟信息里面模拟贵金属账户后再添加该信息
        return customerList;
    }
}